<?php

namespace app\index\model;

use think\Model;

class IndustryNews extends Model
{
    //'http://lclook.oss-cn-shenzhen.aliyuncs.com'
    public function getCreateTimeAttr($value)
    {
        return $value ? date('Y-m-d', $value) : '';
    }

    public function getImageAttr($value)
    {
        return $value ? request()->domain().$value : 'http://lclook.oss-cn-shenzhen.aliyuncs.com/uploads/20210408/ce2490905bb31096fa19bb5c7f7f9d29.png';
    }

    public static function getNews($size = 20)
    {
        return self::where('onlineswitch', 1)->order('weigh desc')->paginate($size);
    }

    public static function getById($id)
    {
        return self::where('id', $id)->find();
    }

    public static function getPreId($id)
    {
        return self::where('id', '<', $id)->value('id');
    }

    public static function getNextId($id)
    {
        return self::where('id', '>', $id)->value('id');
    }
}
